package com.achobeta.recruitment.exception;

import com.achobeta.recruitment.common.AppResult;
import com.achobeta.recruitment.common.ResultCode;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 马拉圈
 * Date: 2023-10-02
 * Time: 0:34
 */

/**
 * 自定义异常
 */
public class ApplicationException extends RuntimeException{

    private static final long serialVersionUID = -3533806916645793660L;

    //异常信息(可能被继承，所以用protected)
    protected AppResult exceptionResult;

    public AppResult getExceptionResult() {
        return exceptionResult;
    }

    public ApplicationException(ResultCode resultCode) {
        super(resultCode.getMessage());
        this.exceptionResult = AppResult.failed(resultCode);
    }

    public ApplicationException(AppResult exceptionResult) {
        super(exceptionResult.getMessage());
        this.exceptionResult = exceptionResult;
    }

    public ApplicationException(String message) {
        super(message);
        this.exceptionResult = AppResult.failed(message);
    }

    public ApplicationException(String message, Throwable cause) {
        super(message, cause);
        this.exceptionResult = AppResult.failed(message);
    }

    public ApplicationException(Throwable cause) {
        super(cause);
        this.exceptionResult = AppResult.failed();
    }
}
